<?php
namespace app\admin\model;

/*
 *表名
 */
class RulesModel extends BaseModel
{
    protected $table = 'xst_rules';
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];
    //查询所有数据并分页
    public function AllData()
    {
        $list=$this->paginate(10);
        $page = $list->render();
        $arr=[$list,$page];
        return $arr;
    }
    //查询所有数据不分页
    public function AllDataNF()
    {
        $list=$this->select();
        return $list;
    }
    //权限的禁止和启用
    public function IsStatus($id,$status){
        $res=$this->where('id',$id)->update(['status'=>$status]);
        if($res){
            if ($status==1)
                $status = ['code'=>1,'msg'=>'开启成功'];
            else
                $status = ['code'=>1,'msg'=>'已禁用'];
        }else{
            if ($status==1)
                $status = ['code'=>0,'msg'=>'开启失败'];
            else
                $status = ['code'=>0,'msg'=>'禁用失败'];
        }
        return $status;
    }
}
